"use strict";
cc._RF.push(module, '52f409W0dNNKK5PdsMGsBpt', 'HallBoxItem');
// scripts/HallBoxItem.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("HallConstant"),
    s = t("BoxGetView"),
    l = t("GlobalUserData"),
    c = t("HallScene"),
    d = t("Util"),
    h = t("Global"),
    p = t("Common"),
    u = cc._decorator,
    f = u.ccclass,
    m = u.property,
    _ = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.pfb_boxView = null, e.node_nONull = null, e.icon_video = null, e.lab_totalNum = null, e.node_boxLight = null, e.node_lock = null, e.node_lockTime = null, e.adTxt = null, e.lab_unlockTime = null, e.nBoxIndex = 0, e.nBoxState = 0, e.nBoxTime = 0, e._hallControl = null, e._parent = null, e.boxData = null, e.nTotalBox = 0, e.videoId = h.VideoTab.Unknown, e.TTVideoIcon = null, e.arrNonEmptyIndex = [], e;
  }

  return n(e, t), e.prototype.updateItem = function (t, e) {
    this._hallControl = e, this._hallControl._hallBoxItem = this, this._parent = t, this.updateView();
  }, e.prototype.start = function () {
    switch (this.adTxt.active = !1, l["default"].isClickBoxNative && (this.adTxt.active = !0), l["default"].curRewardVideoIndex) {
      case 0:
        d.Util.wxReportUseBehavior(h.SceneName.Ads, h.BranchId.VideoAd, 1, "97");
        break;

      case 1:
        d.Util.wxReportUseBehavior(h.SceneName.Ads, h.BranchId.VideoAd, 1, "98");
        break;

      case 2:
        d.Util.wxReportUseBehavior(h.SceneName.Ads, h.BranchId.VideoAd, 1, "99");
    }
  }, e.prototype.updateView = function (t) {
    this.nTotalBox = 0, this.arrNonEmptyIndex.length = 0;

    for (var e = 0; e < l["default"].arrOwnBox.length; e++) {
      var o = l["default"].arrOwnBox[e].state;
      o != r.Box_State.Lock && o != r.Box_State.Unlock && o != r.Box_State.Open || (this.nTotalBox++, this.arrNonEmptyIndex.push(e));
    }

    this.nTotalBox > 0 ? (this.playLightAnim(!0), this.icon_video.active = !1, this.TTVideoIcon.active = !1, this.lab_totalNum.node.parent.active = !0) : (this.playLightAnim(!1), d.Util.is_tt() ? (this.TTVideoIcon.active = !0, this.icon_video.active = !1) : (this.TTVideoIcon.active = !1, this.icon_video.active = !0), this.lab_totalNum.node.parent.active = !1), this.lab_totalNum.string = this.nTotalBox.toString(), t && this.onBtnBox();
  }, e.prototype.playLightAnim = function (t) {
    this.node_boxLight.stopAllActions(), this.node_boxLight.active = t, t && cc.tween(this.node_boxLight).by(4, {
      angle: 360
    }).repeatForever().start();
  }, e.prototype.onBtnBox = function () {
    var t = this;
    if (console.log("主界面打开宝箱"), d.Util.is_qg() && !l["default"].bAuditMode && l["default"].isClickBoxNative && 0 == l["default"].isArenaView && (console.log("点击误触宝箱"), l["default"].isClickBoxNative = !1, d.Util.clickHallBanner()), this.playAudio(r.Audio_ID.btn_click), d.Util.hideSingleCustomAd(!0), d.Util.hideSingleCustomAd(!1), d.Util.wxReportUseBehavior("hall", "btnBox", 2, this._hallControl._strOldUser), this.nTotalBox <= 0) return 0 == l["default"].curRewardVideoIndex && (l["default"].videoTab = 97), void d.Util.showRewardVideo(function () {
      console.log("视频打开"), l["default"].saveBoxData(!0, {
        state: r.Box_State.Lock,
        time: 0
      }), t.updateView(!0);
    });
    d.Util.is_tt() && !l["default"].bAuditMode && d.Util.showInterstitialAd(), d.Util.is_VIVO() && d.Util.showBoxNativeInsertAd(), this.onBoxHandle();
  }, e.prototype.onBoxHandle = function () {
    this.nBoxIndex = this.arrNonEmptyIndex[0], console.log("sadasd");
    var t = cc.instantiate(this.pfb_boxView);
    this._hallControl.node.addChild(t), t.getComponent(s["default"]).showView(s.Box_Type.common, this, this._hallControl), 1 == l["default"].nTotalGame && p["default"].getIns().logEvent(p.LogEventType.Game1GetBox, "", 2);
  }, e.prototype.onOpenBox = function (t) {
    1 == l["default"].nTotalGame && p["default"].getIns().logEvent(p.LogEventType.Box1Open, "", 2), this.nBoxState = r.Box_State.Empty, l["default"].saveBoxData(!1, {
      index: this.nBoxIndex,
      state: this.nBoxState,
      time: 0
    }), l["default"].saveOwnCarData(t), this.updateView(), this.adTxt.active = !1;
  }, e.prototype.playAudio = function (t) {
    this._hallControl.getComponent(c["default"]).playAudio(t);
  }, a([m(cc.Prefab)], e.prototype, "pfb_boxView", void 0), a([m(cc.Node)], e.prototype, "node_nONull", void 0), a([m(cc.Node)], e.prototype, "icon_video", void 0), a([m(cc.Label)], e.prototype, "lab_totalNum", void 0), a([m(cc.Node)], e.prototype, "node_boxLight", void 0), a([m(cc.Node)], e.prototype, "node_lock", void 0), a([m(cc.Node)], e.prototype, "node_lockTime", void 0), a([m(cc.Node)], e.prototype, "adTxt", void 0), a([m(cc.Label)], e.prototype, "lab_unlockTime", void 0), a([m(cc.Node)], e.prototype, "TTVideoIcon", void 0), a([f], e);
}(cc.Component);

o["default"] = _;

cc._RF.pop();